<?php
class msuku extends CI_Model{
	var $suku = "m_suku";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_suku,$nama_suku)
	{
		$this->id_suku= $id_suku;
		$this->nama_suku= $nama_suku;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->suku, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->suku);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{		
		$arrayData = array(
			'id_suku'=>$this->id_suku,
			'nama_suku'=>$this->nama_suku
		);
		return $this->db->insert($this->suku, $arrayData);
	}
	
	function update($id_suku)
	{
		$arrayData = array(
			'nama_suku'=>$this->nama_suku
		);
		$this->db->where('id_suku', $id_suku);
		return $this->db->update($this->suku, $arrayData);
	}
        
	function remove($id_suku)
	{
		$this->db->where('id_suku', $id_suku);
		return $this->db->delete($this->suku);
	}	
	
	function detail($id_suku)
	{
		$this->db->where('id_suku', $id_suku);
		$query = $this->db->get($this->suku);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('nama_suku',$name);
		$query = $this->db->get($this->suku);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
}
?>